package com.meilai.project.constant;

import com.meilai.project.controller.mini.vo.MiniDistanceVO;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;

/**
 * @author 张驰
 * @description 小程序-过滤筛选-项目交付年份
 * @date 2022-08-30 11:10
 */
@Getter
public enum MiniDistanceEnum {
    ALL(1, "全城", null, null, 1),
    ONE_UP(2, "1公里以内", null, new BigDecimal("1000"), 2),
    TWO_UP(3, "2公里以内", null, new BigDecimal("2000"), 3),
    THREE_UP(4, "3公里以内", null, new BigDecimal("3000"), 4),
    FIVE_UP(5, "5公里以内", null, new BigDecimal("5000"), 5);

    private final Integer id;
    private final String name;
    private final BigDecimal min;
    private final BigDecimal max;
    private final Integer sort;

    MiniDistanceEnum(Integer id, String name, BigDecimal min, BigDecimal max, Integer sort) {
        this.id = id;
        this.name = name;
        this.min = min;
        this.max = max;
        this.sort = sort;
    }

    public static List<MiniDistanceVO> getList(){
        SortedMap<Integer, MiniDistanceEnum> map = new TreeMap<Integer, MiniDistanceEnum>();
        for (MiniDistanceEnum enumObj : MiniDistanceEnum.values()) {
            map.put(enumObj.getSort(), enumObj);
        }
        return map.values().stream().map(d ->
            new MiniDistanceVO(
                    d.getId().longValue(),
                    d.getName(),
                    d.getMin(),
                    d.getMax()
            )
        ).collect(Collectors.toList());
    }
}
